<?php
/**
 * Created by PhpStorm.
 * User: xj
 * Date: 2015/3/25
 * Time: 18:21
 */
namespace Admin\Controller;
class LogController extends CommonController
{
    /**
     * log首页
     */
    public function index()
    {
        $this->head();
        $log = M('log');
        if (!$_GET['p']) {
            $_GET['p'] = 1;
        }
        $log_data = $log->page($_GET['p'] . ',10')->select();
        $count = $log->count();
        $page = new PageController($count, 10);
        $page = $page->show();
        $this->assign('page', $page);
        $this->assign('log', $log_data);
        $this->display();
    }

    /**
     * 新增一条日志到LOG表
     * @param  操作内容
     *
     */
    static public function addLog($operate)
    {
        $log = M('log');
        $log_data = array(
            'user_id' => 1,
            'user_name' => 'xujie',
            'operate' => $operate,
            'time' => time(),
        );
        $log->add($log_data);
    }

}